class Student:
    def __init__(self, sid, name, age):
        self.sid = sid
        self.name = name
        self.age = age

    def __str__(self):
        return f"编号:{self.sid}\t姓名：{self.name}\t年纪：{self.age}"


s1 = Student(101, "小张", 20)
# print(s1)
s2 = Student(102, "小李", 21)
# print(s2)

students = []
students.append(s1)
students.append(s2)

for s in students:
    print(s)


class StudentManage:
    def __init__(self):
        self.students = []


    def add_student(self, name, age):
        sid = 101 if not self.students else self.students[-1].sid + 1
        s = Student(sid, name, age)
        self.students.append(s)

    def show_all_students(self):
        for s in self.students:
            print(s)

    def show_student_by_id(self, sid):
        for s in self.students:
            if s.sid == sid:
                print(s)
                break
        else:
            print(f"没有找到sid为{sid}的学生")

    def remove_student_by_id(self, sid):
        for s in self.students:
            if s.sid == sid:
                self.students.remove(s)
                break
        else:
            print(f"没有找到sid为{sid}的学生")

    def show_studnets_age_lt_20(self):
        for s in self.students:
            if s.age < 20:
                print(s)



def main():
    sm = StudentManage()
    sm.add_student("小张", 10)
    sm.add_student("小王", 30)
    sm.show_all_students()

    sm.show_student_by_id(103)
    sm.show_student_by_id(102)

    sm.remove_student_by_id(102)
    sm.show_student_by_id(102)

    sm.show_studnets_age_lt_20()

main()

